package com.hunttown.common.sharding.client.rule.function;

import com.hunttown.common.sharding.client.util.MurmurHash;

public class Hash extends Function<String> {
    public Hash() {
    }

    public long eval(String key) {
        return MurmurHash.hash(key);
    }

    public String parseInput(Object obj) {
        if (obj instanceof String) {
            return (String) obj;
        } else if (obj != null) {
            return String.valueOf(obj);
        } else {
            throw new IllegalArgumentException("[Function#Hash]Input cann't be transfered to String!");
        }
    }
}